package cn.uniqueinfo.dp.util;

import cn.uniqueinfo.dp.enums.ResultCodeEnum;
import cn.uniqueinfo.dp.vo.Result;

/**
 * @author:朱元勋
 * @mail:395910063@qq.com
 * @date:2019-01-04 10:45:26
 * @description: 返回结果工具类 减少重复代码，保证返回值的统一性
 */
public class ResultUtil {

    public static Result success(){
        return new Result(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg(),null);
    }

    public static<T> Result success(T data){
        return new Result(ResultCodeEnum.SUCCESS.getCode(),ResultCodeEnum.SUCCESS.getMsg(),data);
    }

    public static Result fail(){
        return new Result(ResultCodeEnum.FAIL.getCode(),ResultCodeEnum.FAIL.getMsg(),null);
    }

    public static<T> Result fail(T data){
        return new Result(ResultCodeEnum.FAIL.getCode(),ResultCodeEnum.FAIL.getMsg(),data);
    }
}
